package com.knowif.service;

import com.knowif.dao.ProductMapper;
import com.knowif.pojo.Product;
import com.knowif.pojo.ProductExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xingyao
 * @Description: 栏目管理dao服务层
 */
@Service
public class Product_service {

    @Autowired
    private ProductMapper productMapper;

    /**
     * 类目查询
     * @param productExample
     * @return
     */
    public List<Product> selectProduct(ProductExample productExample){
        return productMapper.selectByExample(productExample);
    }

    /**
     * 插入product
     * @param product
     * @return
     */
    public int saveProduct(Product product){
        return productMapper.insert(product);
    }

    /**
     * 更新不为空的product属性
     * @param product
     * @return
     */
    public int updateProductNotNull(Product product){
        return productMapper.updateByPrimaryKeySelective(product);
    }

    /**
     * 更新所有product属性
     * @param product
     * @return
     */
    public int updateProduct(Product product){
        return productMapper.updateByPrimaryKey(product);
    }

    /**
     * 删除product
     * @param productId
     */
    public int deleteProduct(int productId){
        return productMapper.deleteByPrimaryKey(productId);
    }

    /**
     * 主键查找
     * @param productId
     * @return
     */
    public Product selectByPrimaryKey(int productId){
        return productMapper.selectByPrimaryKey(productId);
    }

}
